﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Data.Objects.DataClasses;
using System.ServiceModel.DomainServices.Server;
using System.Collections.ObjectModel;
using RIA.ServicesLibrary.Web.Models;
using RIA.ServicesLibrary.Web.Models.Shared.CustomValidationRules;

namespace RIA.ServicesLibrary.Web.Models
{
    // The MetadataTypeAttribute identifies CustomerMetadata as the class
    // that carries additional metadata for the Customer class.
    [MetadataTypeAttribute ( typeof ( Customer.CustomerMetadata ) )]
    public partial class Customer
    {

        // This class allows you to attach custom attributes to properties
        // of the Customer class.
        //
        // For example, the following marks the Xyz property as a
        // required property and specifies the format for valid values:
        //    [Required]
        //    [RegularExpression("[A-Z][A-Za-z0-9]*")]
        //    [StringLength(32)]
        //    public string Xyz { get; set; }
        internal sealed class CustomerMetadata
        {

            // Metadata classes are not meant to be instantiated.
            private CustomerMetadata ()
            {
               
            }

            [CustomValidation ( typeof ( CustomerPhoneValidator ), "CrossValidatePhoneWithHasPhone" )]
            [RegularExpression ( @"^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$", ErrorMessage = "..." )]
            public string Phone { get; set; }

            [CustomValidation ( typeof ( CustomerPhoneValidator ), "CrossValidateHasPhoneWithPhone" )]
            public bool HasPhone { get; set; }

            [Include]
            public EntityCollection<CustomerAddress> CustomerAddresses { get; set; }


        }
    }

    [MetadataTypeAttribute ( typeof ( CustomerAddress.CustomerAddressMetadata ) )]
    public partial class CustomerAddress
    {
        internal sealed class CustomerAddressMetadata
        {

            // Metadata classes are not meant to be instantiated.
            private CustomerAddressMetadata ()
            {

            }

            [Include]
            //[Composition]
            public Address Address
            {
                get;
                set;
            }

        }
    }
}

